<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

</h:head>
<body>
	<h:form id="frmCadFigura">
		<br />
		<h3 style="margin-top: 0">CADASTRO DE FIGURA FISCAL</h3>
		<div align="left">
			<p:commandButton value="Novo"
				actionListener="#{figuraFiscalBean.novo}" ajax="grid" />

			<p:commandButton value="Salvar" disabled="#{figuraFiscalBean.sal}"
				actionListener="#{figuraFiscalBean.salvar}" ajax="grid" />

			<p:commandButton value="Alterar" disabled="#{figuraFiscalBean.alt}"
				actionListener="#{figuraFiscalBean.alterar}" ajax="grid" />

			<p:commandButton value="Excluir" disabled="#{figuraFiscalBean.rem}"
				actionListener="#{figuraFiscalBean.remover}" ajax="grid" />

			<p:commandButton id="consulta" value="Consulta"
				action="#{pesquisaFiguraFiscalBean.abrirDialogo}">
				<p:ajax event="dialogReturn" listener="#{figuraFiscalBean.figuraFiscalSelecionado}" update="frmCadFigura"/>
			</p:commandButton>

			<p:commandButton value="Cancelar"
				actionListener="#{figuraFiscalBean.cancelar}" ajax="grid" />
			<p:messages id="messages" showDetail="true" autoUpdate="true"
				closable="true" />

			<h:panelGrid id="grid" columns="2" columnClasses="label, value">
					Código da Figura:
					<p:inputText id="idFig" disabled="true"
					value="#{figuraFiscalBean.figura.idFigura}" />
					
					Descrição da Figura:
					<p:inputText id="desc" value="#{figuraFiscalBean.figura.descricao}"
					disabled="#{figuraFiscalBean.desc}" />
			</h:panelGrid>

			<p:commandButton id="diGrade" value="Vincular Grade" type="button"
				disabled="#{figuraFiscalBean.vincGrade}"
				onclick=" PF('dlg2').show();" />

			<h:panelGrid id="gridGrade" columns="1">
				<p:blockUI block="gridGrade" trigger="gridGrade" />
				<p:dataTable id="listaGrade" value="#{figuraFiscalBean.listaGrade}"
					var="listaGrade" paginator="true" rows="8">

					<p:column headerText="Código da Grade">
						<h:outputText value="#{listaGrade.idGradeTrib}" />
					</p:column>

					<p:column headerText="Descrição da Grade">
						<h:outputText value="#{listaGrade.descricao}" />
					</p:column>

					<p:column headerText="Excluir">
						<p:commandLink id="linkExcluiGrade" value="Excluir" ajax="dialog"
							action="#{figuraFiscalBean.excluirGrade}" update="listaGrade">
							<f:setPropertyActionListener value="#{listaGrade.idGradeTrib}"
								target="#{figuraFiscalBean.idGrade}" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
				<p:blockUI block="listaGrade" trigger="listaGrade">
        				LOADING<br />
					<p:graphicImage name="ajaxloader.gif" />
				</p:blockUI>
			</h:panelGrid>
			<p:dialog id="dialog3" header="Consulta" widgetVar="dlg3"
				modal="true" height="300" width="650">

				<div align="right">
					<h:panelGrid columns="1">
						<p:commandButton value="Pesquisar"
							actionListener="#{figuraFiscalBean.buscar}" update="gridData">
						</p:commandButton>
					</h:panelGrid>
				</div>
				<h:panelGrid columns="3" columnClasses="label" cellspacing="3">
					<p:inputText id="texto" value="#{figuraFiscalBean.busca}" size="40" />

					<p:selectOneMenu id="fConsult" value="#{figuraFiscalBean.filtro}">/>
						<f:selectItem itemLabel="Selecione uma Opção" />
						<f:selectItem itemLabel="Código" itemValue="id" />
						<f:selectItem itemLabel="Descrição" itemValue="des" />
					</p:selectOneMenu>

				</h:panelGrid>
				<h:panelGrid id="gridData" columns="1" columnClasses="label, value">
					<p:blockUI block="gridData" trigger="consulta" />
					<p:dataTable id="data" value="#{figuraFiscalBean.listaFigura}"
						paginator="true" rows="6" var="listFigura"
						rowKey="listFigura.idFigura">

						<p:column headerText="Código da Figura">
							<h:outputText value="#{listFigura.idFigura}" />
						</p:column>

						<p:column headerText="Descrição">
							<h:outputText value="#{listFigura.descricao}" />
						</p:column>

						<p:column headerText="Selecionar">
							<p:commandLink id="link" value="Editar"
								ajax="grid, dialog3, gridGrade"
								action="#{figuraFiscalBean.editFigura}">
								<f:setPropertyActionListener value="#{listFigura.idFigura}"
									target="#{figuraFiscalBean.id}" />
							</p:commandLink>
						</p:column>
					</p:dataTable>
					<p:blockUI block="data" trigger="data">
        				LOADING<br />
						<p:graphicImage name="ajaxloader.gif" />
					</p:blockUI>
				</h:panelGrid>
			</p:dialog>

			<p:dialog id="dialog" header="Incluir Grade Tributaria"
				widgetVar="dlg2" modal="true" height="100" width="400">
				<h:panelGrid id="gridincEdi2" columns="1"
					columnClasses="label, value">
					
					Grade:
					<p:selectOneMenu id="grade" style="width:350px;"
						value="#{figuraFiscalBean.grade}">
						<f:selectItem itemLabel="Selecione uma grade" />
						<f:selectItems value="#{figuraFiscalBean.listaGradeVis}"
							var="listGrade" itemValue="#{listGrade}"
							itemLabel="#{listGrade.idGradeTrib} - #{listGrade.descricao}" />
					</p:selectOneMenu>

				</h:panelGrid>

				<p:tooltip id="toolTipAliq" for="grade"
					value="Exibição 'Código' - 'Descrição'" showEffect="clip"
					hideEffect="explode" />

				<p:commandButton value="Incluir"
					actionListener="#{figuraFiscalBean.incluirGrade}"
					update="listaGrade, gridincEdi2" />
			</p:dialog>

		</div>
	</h:form>
</body>
</html>
